package com.guoqi.wolf2w.controller;


import com.guoqi.wolf2w.domain.UserInfo;
import com.guoqi.wolf2w.redis.IUserInfoRedisService;
import com.guoqi.wolf2w.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("user")
public class UserInfoController {

    @Autowired
    private IUserInfoService service;
    @Autowired
    private IUserInfoRedisService redisService;

    @RequestMapping("get")
    @ResponseBody
    public UserInfo findNameByPhone(String phone){
        return service.findNicknameByPhone(phone);
    }

    @RequestMapping("login")
    @ResponseBody
    public String login(String phone){
        return redisService.setToken(phone,service.findNicknameByPhone(phone));
    }


}
